package com.bootssm.service.impl;

import com.bootssm.dao.ScheduleMapper;
import com.bootssm.entity.Schedule;
import com.bootssm.entity.ScheduleVO;
import com.bootssm.service.ScheduleService;
import com.bootssm.utils.IdWorker;
import com.bootssm.utils.TimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
@Service
public class ScheduleServiceImpl implements ScheduleService {

    @Autowired
    ScheduleMapper scheduleMapper;

    @Override
    public List<Schedule> findAll(ScheduleVO scheduleVO) {
        return scheduleMapper.findAll(scheduleVO);
    }

    @Override
    public Integer getCount(ScheduleVO scheduleVO) {
        return scheduleMapper.getCount(scheduleVO);
    }

    @Override
    public void deleteById(String id) {
        scheduleMapper.deleteById(id);
    }

    @Override
    public void update(ScheduleVO scheduleVO) {
scheduleMapper.update(scheduleVO);
    }

    @Autowired
    IdWorker idWorker;

    @Override
    public void save(ScheduleVO scheduleVO) {
       scheduleVO.setScheduleid(idWorker.nextId()+"");
        scheduleVO.setTimeid(idWorker.nextId()+"");

        scheduleVO.setTime(TimeUtil.getCurrentTime(new Date()));
        scheduleMapper.save(scheduleVO);
    }
}
